<template>
  <Layout>
    <div style="min-height: 600px">
      <el-card shadow="never" style="min-height: 400px">
        <div slot="header">
          <el-row>
            <el-col :span="12">
              <span>{{ blog.name }}</span>
            </el-col>
            <el-col :span="12">
              <div style="text-align: right;">
                <el-button
                  style="padding: 3px 0"
                  type="text"
                  icon="el-icon-share"
                  >分享</el-button
                >
                <el-button
                  @click="toGithub(blog.url)"
                  style="padding: 3px 0"
                  type="text"
                  icon="el-icon-back"
                >
                  前往Github
                </el-button>
                <el-button
                  @click="toGithub(blog.url)"
                  style=" padding: 3px 0"
                  type="text"
                  icon="el-icon-more-outline"
                  >更多项目</el-button
                >
              </div>
            </el-col>
          </el-row>
        </div>
        <div style="font-size: 0.9rem;line-height: 1.5;color: #606c71;">
          发布 {{ blog.createTime | date }} <br />
          更新 {{ blog.updateTime | date }}
        </div>
        <div
          style="font-size: 1.1rem;line-height: 1.5;color: #303133;border-bottom: 1px solid #E4E7ED;padding: 5px 0px 5px 0px"
        >
          <pre style="font-family: '微软雅黑'">{{ blog.description }}</pre>
        </div>
        <div
          v-html="readme"
          class="markdown-body"
          style="padding-top: 20px"
        ></div>
      </el-card>
    </div>
  </Layout>
</template>

<page-query>
query($id: ID!) {
	project(id: $id) {
    id
    name
    description
    updateTime
    stargazersCount
    watchersCount
    forksCount
    url
    language
    license
    readme
  }
}
</page-query>

<script>
import markdown from '~/utils/markdown'

export default {
  name: 'ProjectDetail',
  metaInfo: {
    title: '项目详情'
  },
  computed: {
    blog () {
      return this.$page.project
    },
    readme () {
      return markdown(this.blog.readme)
    }
  },
  methods: {
    toGithub (url) {
      window.open(url, '_blank')
    }
  }
}
</script>

<style></style>
